﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Thuoc24h.Data;
using Thuoc24h.Common;

namespace Thuoc24h.Views.Shared
{
    public partial class ShopCartSmall : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["Order"] != null)
            {
                NotEmptyCartPanel.Visible = true;
                EmptyCartPanel.Visible = false;
                var order = (List<ShopCartEntity>)Session["Order"];
                ProductCountLtr.Text = order.Count() + "";
                double? priceTotal = 0;
                for (int i = 0; i < order.Count(); i++)
                {
                    priceTotal += order[i].Price * order[i].Quantity;
                }

                TotalPriceLtr.Text += double.Parse(priceTotal.ToString()).ToString("#,###");
            }
            else
            {
                NotEmptyCartPanel.Visible = false;
                EmptyCartPanel.Visible = true;
            }
        }
    }
}